﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TinyCinema.UI.Pages.Customer
{
    /// <summary>
    /// Interaction logic for Type.xaml
    /// </summary>
    public partial class Type : Page
    {
        public StackPanel MainMenu { get; set; }
        public static DependencyProperty ContentFrameSourceProperty = DependencyProperty.Register("pagContentFrameSource", typeof(Page), typeof(Type));
        public Page pagContentFrameSource
        {
            get { return (Page)GetValue(ContentFrameSourceProperty); }
            set { SetValue(ContentFrameSourceProperty, value); }
        }
        public static TinyCinema.Bussiness.Customer.Type dataContext = new TinyCinema.Bussiness.Customer.Type();
        public Type()
        {
            InitializeComponent();
            MainMenu = FindResource("MainMenu") as StackPanel;
            DataContext = dataContext;
            (DataContext as Bussiness.Customer.Type).Messenger.Register<Bussiness.Customer.Message.BackConfimation>(this, ShowMessageBox1);
            (DataContext as Bussiness.Customer.Type).Messenger.Register<Bussiness.Customer.Message.BackConfimationOK>(this, (s) => MainPage.pagType.FormViewModeHandle()); 
            (DataContext as Bussiness.Customer.Type).Messenger.Register<Bussiness.Customer.Message.DeleteFailed>(this, ShowMessageBox2);
            (DataContext as Bussiness.Customer.Type).Messenger.Register<Bussiness.Customer.Message.DeleteConfirmation>(this, ShowMessageBox3);
        }
        void ShowMessageBox1(Bussiness.Customer.Message.BackConfimation s)
        {
            s.Result = MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgExit") as String), "", MessageBoxButton.YesNo);
        }
        void ShowMessageBox2(Bussiness.Customer.Message.DeleteFailed s)
        {
            MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgCusTypeNotDelete") as String), "", MessageBoxButton.OK);
        }
        void ShowMessageBox3(Bussiness.Customer.Message.DeleteConfirmation s)
        {
            s.Result = MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgCusTypeDelete") as String), "", MessageBoxButton.YesNo);
        }
        private void MainMenuInitialized(object sender, EventArgs e)
        {
            (sender as StackPanel).DataContext = dataContext;
        }
        public void FormViewModeHandle()
        {
            if (pagContentFrameSource is Type) ViewModeHandle(btnPreViewMode, null);
        }
        Button btnPreViewMode;
        private void ViewModeHandle(object sender, EventArgs e)
        {
            switch ((sender as Button).Uid)
            {
                case "GridView": pagContentFrameSource = new _Type.GridView();
                    break;
                case "ListView":
                    break;
            }
            (sender as Button).IsEnabled = false;
            try { btnPreViewMode.IsEnabled = true; }
            catch { }
            btnPreViewMode = sender as Button;

        }

    }

}
